package com.xzy.springboot.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import java.util.UUID;

@EnableBinding(Source.class)   //开启消息管道
public class ProvideMessageImpl implements IprovideMessage {

     //channel实体
     @Autowired
     private MessageChannel output;



     @Override
     public String send() {
         String UUId = UUID.randomUUID().toString();

        output.send(MessageBuilder.withPayload(UUId).build());  //创建消息实体并通过channel发送

        return UUId;
    }
}
